PREVIEW: This is an example of the feed the fish game you will make today!

  • Click Run to start the game.
  • Use the left and right arrow keys on your keyboard to catch the falling food!
  • After you play the game, click Submit and Next to build it yourself!

Click Submit and Next after every activity in this lesson to move to the next activity.

To navigate the page using the TAB key, first press ESC to exit the code editor.

stage.set_background("underwater") sprite = codesters.Sprite("fish1", 0, -220) stage.set_gravity(4) stage.disable_floor() sprite.gravity_off() score = 0 score_board = codesters.Display(score) def interval(): x = random.randint(-260, 260) food = codesters.Circle(x, 230, 10, "sienna") # add any other actions... stage.event_interval(interval, 2) def left(): sprite.move_left(30) # add other actions... stage.event_left_key(left) def right(): sprite.move_right(30) # add other actions... stage.event_right_key(right) def collision(sprite, hit_sprite): stage.remove_sprite(hit_sprite) global score score += 1 score_board.update(score) sprite.turn_right(360) sprite.set_say_color("red") sprite.say("YUM!", 0.5) # add any other actions... sprite.event_collision(collision)
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)